import type { MaProTableColumns, MaProTableExpose } from '@mineadmin/pro-table'
import type { UseDialogExpose } from '@/hooks/useDialog.ts'
import { useMessage } from '@/hooks/useMessage.ts'
import { deleteByIds, resetPassword } from '~/base/api/user.ts'
import { ResultCode } from '@/utils/ResultCode.ts'
import MaUploadImage from "@/components/ma-upload-image/index.vue";

export default function getTableColumns(dialog: UseDialogExpose, formRef: any,CardChange: any): MaProTableColumns[] {
  const msg = useMessage()
  return [
    // 多选列
    { type: 'selection', showOverflowTooltip: false},

    // 索引序号列
    // { type: 'index' },
    // 普通列
    { label: '模版ID', prop: 'id' },
    { label: '卡库名称', prop: 'xxx', width:250},
    { label: '类型', prop: 'xxx' },
    { label: '卡号别名', prop: 'xxx' },
    { label: '卡密别名', prop: 'xxx' },
    { label: '库存数量', prop: 'xxx' },
    { label: '库存成本', prop: 'xxx' },
    { label: '库存成本权重', prop: 'xxx' },
    { label: '报警数量', prop: 'xxx' },
    { label: '创建时间', prop: 'xxx' },
    // 操作列
    {
      type: 'operation',
      label:'操作',
      fixed: 'right',
      width: '220px',
      operationConfigure: {
        type: 'tile',
        actions: [
          {
            name: 'edit',
            icon: 'material-symbols:person-edit',
            text: '编辑',
            onClick: ({ row }) => {
              dialog.setTitle('编辑')
              dialog.open({ formType: 'edit', data: row })
            },
          },
          {
            name: 'del',
            icon: 'mdi:delete',
            text: '删除',
            onClick: ({ row }, proxy: MaProTableExpose) => {
              msg.delConfirm('是否删除').then(async () => {
                const response = await deleteByIds([row.id])
                if (response.code === ResultCode.SUCCESS) {
                  msg.success('删除成功')
                  proxy.refresh()
                }
              })
            },
          },
          {
            name: 'importCard',
            text: '导卡',
            onClick: ({ row }) => {
              CardChange('importCard',row)
            },
          },
          {
            name: 'searchCard',
            text: '查卡',
            onClick: ({ row }) => {
              CardChange('searchCard',row)
            },
          }
        ],
      },
    },
  ]
}
